package com.duowan.realtime.webservice.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.duowan.realtime.model.BloomfilterGroup;
import com.duowan.realtime.model.BloomfilterInfo;
import com.duowan.realtime.model.OverviewBloomfilter;
import com.duowan.realtime.model.OverviewComputingGroup;
import com.duowan.realtime.service.BloomfilterGroupService;
import com.duowan.realtime.service.BloomfilterInfoService;
import com.duowan.realtime.service.OverviewBloomfilterService;
import com.duowan.realtime.service.OverviewComputingGroupService;
import com.duowan.realtime.service.ServerInfoService;
import com.duowan.realtime.webservice.DataComputingWebService;

@Service("bloomFilterWebService")
public class DataComputingWebServiceImpl implements DataComputingWebService {

	private BloomfilterGroupService bloomfilterGroupService;
	private ServerInfoService serverInfoService;
	private OverviewBloomfilterService overviewBloomfilterService;
	private BloomfilterInfoService bloomfilterInfoService;
	private OverviewComputingGroupService overviewComputingGroupService;

	public void setBloomfilterGroupService(BloomfilterGroupService bloomfilterGroupService) {
		this.bloomfilterGroupService = bloomfilterGroupService;
	}

	public void setOverviewComputingGroupService(
			OverviewComputingGroupService overviewComputingGroupService) {
		this.overviewComputingGroupService = overviewComputingGroupService;
	}



	public void setBloomfilterInfoService(BloomfilterInfoService bloomfilterInfoService) {
		this.bloomfilterInfoService = bloomfilterInfoService;
	}
	
	public void setServerInfoService(ServerInfoService serverInfoService) {
		this.serverInfoService = serverInfoService;
	}

	public void setOverviewBloomfilterService(OverviewBloomfilterService overviewBloomfilterService) {
		this.overviewBloomfilterService = overviewBloomfilterService;
	}

	@Override
	public String getServerIp(String realtimeComputingGroup) {
		return serverInfoService.getServerIp(realtimeComputingGroup).getIp();
	}

	@Override
	public boolean checkBloomFilterExists(String bloomfilterGroup) {
		return bloomfilterGroupService.checkBloomFilterExists(bloomfilterGroup);
	}

	@Override
	public List<OverviewBloomfilter> getBFListByBFGroup(String bloomfilterGroup) {
		return overviewBloomfilterService.getByBloomFilterGroup(bloomfilterGroup);
	}

	@Override
	public OverviewBloomfilter reportBFStatus(OverviewBloomfilter overviewBloomfilter) {
		return overviewBloomfilterService.update(overviewBloomfilter);

	}

	@Override
	public List<OverviewBloomfilter> getBFListByServerIp(String serverIp) {
		
		return overviewBloomfilterService.getByServerIp(serverIp);
	}

	@Override
	public BloomfilterGroup getByBloomfilterGroup(String bloomfilterGroup) {
		return bloomfilterGroupService.getByBloomfilterGroup(bloomfilterGroup);
	}

	@Override
	public void removeBloomfilter(String bloomfilterGroup, String bloomfilterName, String partition) {
		overviewBloomfilterService.removeById(bloomfilterGroup, bloomfilterName,partition);
	}

	@Override
	public List<BloomfilterGroup> getBFGroupMetaDatas() {
		return bloomfilterGroupService.getMetaDatas();
	}

	@Override
	public List<BloomfilterInfo> getBloomfilterInfos() {
		return bloomfilterInfoService.getBloomfilterInfos();
	}

	@Override
	public BloomfilterInfo reportBFInfo(BloomfilterInfo bloomfilterInfo) {
		return bloomfilterInfoService.update(bloomfilterInfo);
	}

	@Override
	public void removeBloomfilterInfo(int id) {
		bloomfilterGroupService.removeById(id);
		
	}

	@Override
	public OverviewComputingGroup reportDCGroupStatus(OverviewComputingGroup overviewComputingGroup) {
		return overviewComputingGroupService.create(overviewComputingGroup);
	}

}
